<ion-header>
    <ion-toolbar>
        <ion-buttons slot="start">
            <ion-back-button [text]="'core.back' | translate" />
        </ion-buttons>
        <ion-title>
            <h1>{{ 'addon.mod_workshop.editsubmission' | translate }}</h1>
        </ion-title>
        <ion-buttons slot="end">
            <ion-button fill="clear" (click)="save()" [ariaLabel]="'core.save' | translate">
                {{ 'core.save' | translate }}
            </ion-button>
        </ion-buttons>
    </ion-toolbar>
</ion-header>
<ion-content>
    <core-loading [hideUntil]="loaded">
        @if (workshop) {
            <form [formGroup]="editForm" #editFormEl>
                <ion-item class="ion-text-wrap">
                    <ion-input labelPlacement="stacked" name="title" type="text"
                        [placeholder]="'addon.mod_workshop.submissiontitle' | translate" formControlName="title">
                        <div [core-mark-required]="true" slot="label">
                            {{ 'addon.mod_workshop.submissiontitle' | translate }}
                        </div>
                    </ion-input>
                </ion-item>

                @if (textAvailable) {
                    <ion-item>
                        <ion-label position="stacked">
                            <div [core-mark-required]="textRequired">
                                {{ 'addon.mod_workshop.submissioncontent' | translate }}
                            </div>
                        </ion-label>
                        <core-rich-text-editor [control]="editForm.controls['content']" name="content"
                            [placeholder]="'addon.mod_workshop.submissioncontent' | translate" [component]="component"
                            [componentId]="componentId" [autoSave]="true" contextLevel="module" [contextInstanceId]="module.id"
                            elementId="content_editor" [draftExtraParams]="editorExtraParams" />
                    </ion-item>
                }

                @if (fileAvailable) {
                    <core-attachments [files]="attachments" [maxSize]="workshop.maxbytes" [maxSubmissions]="workshop.nattachments"
                        [component]="component" [componentId]="workshop.coursemodule" [allowOffline]="true"
                        [acceptedTypes]="workshop.submissionfiletypes" [required]="fileRequired" [courseId]="workshop.course" />
                }
            </form>
        }
    </core-loading>
</ion-content>
